package com.yuandian.api.customer_perception.vo;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.List;

/**
 * 类说明: 全系统/业务 TOP 分析总览vo
 *
 * @Date 2021/8/19 9:26
 * @Author User
 */
@Getter
@Setter
@ToString
public class TopAnalysisOverviewVo {

    /**
     * 系统ID
     */
    private Integer systemId;

    /**
     * 系统名称
     */
    private String systemName;

    /**
     * 业务编码
     */
    private String businessCode;

    /**
     * 业务编码
     */
    private String businessName;

    /**
     * 系统/业务Id
     */
    private String completeId;
    private String completeCode;

    /**
     * 受理量最多的系统/业务
     */
    private String completeName;

    /**
     * 受理量
     */
    private Integer completeCount;

    /**
     * 历史峰值/谷值
     */
    private Integer minCompleteCount;
    private Integer maxCompleteCount;

    /**
     * 系统/业务Id
     */
    private String failId;
    private String failCode;

    /**
     * 失败量最多的系统/业务
     */
    private String failName;

    /**
     * 失败量
     */
    private Integer failCount;

    /**
     * 历史峰值/谷值
     */
    private Integer minFailCount;
    private Integer maxFailCount;

    /**
     * 系统/业务ID
     */
    private String avgVisitTimeId;
    private String avgVisitTimeCode;


    /**
     * 人工平均操作耗时最长的系统/业务
     */
    private String avgVisitTimeName;

    /**
     * 人工平均操作耗时
     */
    private Long avgVisitTime;


    /**
     * 系统/业务ID
     */
    private String avgResponseTimeId;
    private String avgResponseTimeCode;


    /**
     * 系统平均响应耗时最长的系统/业务
     */
    private String avgResponseTimeName;

    /**
     * 系统平均响应耗时
     */
    private Long avgResponseTime;


    /**
     * 系统/业务ID
     */
    private String avgDealTimeId;
    private String avgDealTimeCode;
    private String avgDealTimeName;

    /**
     * 业务平均办理耗时
     */
    private Long avgDealTime;


    /**
     * 排序 asc-升序  desc-降序
     */
    private String orderBy;



    public static TopAnalysisOverviewVo build (List<TopAnalysisOverviewVo> complete,
                                               List<TopAnalysisOverviewVo> fail,
                                               List<TopAnalysisOverviewVo> visitTime,
                                               List<TopAnalysisOverviewVo> responseTime,
                                               List<TopAnalysisOverviewVo> dealTime) {
        TopAnalysisOverviewVo overviewVo = new TopAnalysisOverviewVo();

        // 受理量
        if (null != complete && complete.size() >= 1) {
            overviewVo.setCompleteId(complete.get(0).getCompleteId());
            overviewVo.setCompleteCode(complete.get(0).getCompleteCode());
            overviewVo.setCompleteName(complete.get(0).getCompleteName());
            overviewVo.setCompleteCount(complete.get(0).getCompleteCount());
        }

        // 失败量
        if (null != fail && fail.size() >= 1) {
            overviewVo.setFailId(fail.get(0).getFailId());
            overviewVo.setFailCode(fail.get(0).getFailCode());
            overviewVo.setFailName(fail.get(0).getFailName());
            overviewVo.setFailCount(fail.get(0).getFailCount());
        }

        // 人工操作耗时
        if (null != visitTime && visitTime.size() >= 1) {
            overviewVo.setAvgVisitTimeId(visitTime.get(0).getAvgVisitTimeId());
            overviewVo.setAvgVisitTimeCode(visitTime.get(0).getAvgVisitTimeCode());
            overviewVo.setAvgVisitTimeName(visitTime.get(0).getAvgVisitTimeName());
            overviewVo.setAvgVisitTime(visitTime.get(0).getAvgVisitTime());
        }

        // 响应耗时
        if (null != responseTime && responseTime.size() >= 1) {
            overviewVo.setAvgResponseTimeId(responseTime.get(0).getAvgResponseTimeId());
            overviewVo.setAvgResponseTimeCode(responseTime.get(0).getAvgResponseTimeCode());
            overviewVo.setAvgResponseTimeName(responseTime.get(0).getAvgResponseTimeName());
            overviewVo.setAvgResponseTime(responseTime.get(0).getAvgResponseTime());
        }

        if (null != dealTime && dealTime.size() >= 1) {
            overviewVo.setAvgDealTimeId(dealTime.get(0).getAvgDealTimeId());
            overviewVo.setAvgDealTimeCode(dealTime.get(0).getAvgDealTimeCode());
            overviewVo.setAvgDealTimeName(dealTime.get(0).getAvgDealTimeName());
            overviewVo.setAvgDealTime(dealTime.get(0).getAvgDealTime());
        }

        return overviewVo;
    }


    /**
     * 系统名称转换
     */
    public void translateSystem () {
        if (null != completeId) {
            systemId = Integer.parseInt(completeId);
        }
        if (null != completeName) {
            systemName = completeName;
        }

        if (null != failId) {
            systemId = Integer.parseInt(failId);
        }
        if (null != failName) {
            systemName = failName;
        }

        if (null != avgVisitTimeId) {
            systemId = Integer.parseInt(avgVisitTimeId);
        }
        if (null != avgVisitTimeName) {
            systemName = avgVisitTimeName;
        }

        if (null != avgResponseTimeId) {
            systemId = Integer.parseInt(avgResponseTimeId);
        }
        if (null != avgResponseTimeName) {
            systemName = avgResponseTimeName;
        }

        if (null != avgDealTimeId) {
            systemId = Integer.parseInt(avgDealTimeId);
        }
        if (null != avgDealTimeName) {
            systemName = avgDealTimeName;
        }
    }


    /**
     * 业务名称转换
     */
    public void translateBusiness () {
        if (null != completeCode) {
            businessCode = completeCode;
        }
        if (null != completeName) {
            businessName = completeName;
        }

        if (null != failCode) {
            businessCode = failCode;
        }
        if (null != failName) {
            businessName = failName;
        }

        if (null != avgVisitTimeCode) {
            businessCode = avgVisitTimeCode;
        }
        if (null != avgVisitTimeName) {
            businessName = avgVisitTimeName;
        }

        if (null != avgResponseTimeCode) {
            businessCode = avgResponseTimeCode;
        }
        if (null != avgResponseTimeName) {
            businessName = avgResponseTimeName;
        }

        if (null != avgDealTimeCode) {
            businessCode = avgDealTimeCode;
        }
        if (null != avgDealTimeName) {
            businessName = avgDealTimeName;
        }
    }

}
